package com.ruoyi.data.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.annotation.DataColumn;
import com.ruoyi.common.annotation.DataPermission;
import com.ruoyi.data.domain.DataClassification;
import com.ruoyi.data.domain.bo.DataClassificationBo;
import com.ruoyi.data.domain.vo.DataClassificationVo;
import com.ruoyi.common.core.mapper.BaseMapperPlus;
import org.apache.ibatis.annotations.Param;

import java.util.Collection;
import java.util.List;

/**
 * 分类管理Mapper接口
 *
 * @author ruoyi
 * @date 2023-10-26
 */
public interface DataClassificationMapper extends BaseMapperPlus<DataClassificationMapper, DataClassification, DataClassificationVo> {

    /**
     * 按分享类型 查询分类数据
     * @param userId
     * @param classificationType
     * @return
     */
    List<DataClassificationVo> selectClassificationByIdUserId(@Param("userId")Long userId, @Param("dc")DataClassificationBo classificationType);

    /**
     * 按用户删除 分享类型
     * @param userId
     * @return
     */
    Boolean deleteDataClassificationByUserId(@Param("userId")Long userId,@Param("dc") DataClassificationBo dataClassification);

    /**
     * 分页查询分类数据
     * @return
     */
    @DataPermission({
        @DataColumn(key = "userName", value = "u.user_id"),
        @DataColumn(key = "deptName", value = "d.dept_id"),

    })
    Page<DataClassification> selectDataClassificationVoPage(@Param("page") Page<Object> page,  @Param(Constants.WRAPPER) QueryWrapper<DataClassification> wrapper);

    /**
     * 物理删除
     * @param ids
     * @return
     */
    int physicsDeleteBatchIds(@Param(Constants.COLL) Collection<Long> ids);

    /**
     * 查询当前用户名称类型 是否存在分类
     * @param classificationName
     * @param classificationType
     * @param userId
     * @return
     */
    DataClassification selectDataClassificationByValidEntityBeforeSave(@Param("classificationName") String classificationName, @Param("classificationType")String classificationType, @Param("userId")Long userId);
}
